package com.maoxs.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.maoxs.util.DateTimeUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * 填充器
 *
 * @author fulin
 * @since 2018-09-12
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
        metaObject.setValue("createDate", DateTimeUtils.getCurrentLocalDateTime());
    }

    @Override
    public void updateFill(MetaObject metaObject) {

        this.setFieldValByName("createDate",DateTimeUtils.getCurrentLocalDateTime(), metaObject);
    }
}
